#pragma once
#include <iostream>
#include <string>
#include <functional>

class Task
{
    using func_t = function<void(int cfd, const std::string &client_info)>;

public:
    Task() = default;

    Task(int cfd, const std::string &client_info, func_t cb)
        : _cfd(cfd), _client_info(client_info), _cb(cb)
    {
    }

    void operator()()
    {
        _cb(_cfd, _client_info);
    }

private:
    int _cfd;                 // 客户端套接字文件描述符
    std::string _client_info; // 客户端信息
    func_t _cb;               // 回调函数
};